package com.zpphis.controller;

import com.zpphis.service.IConstantItemService;
import com.zpphis.service.IConstantTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/constant")
public class ConstantController {

    @Autowired
    private IConstantTypeService constantTypeService;
    @Autowired
    private IConstantItemService constantItemService;

    @RequestMapping("/itemTable.json")
    public Map<String, Object> itemTable() {
        return new HashMap<String, Object>() {
            {
                put("code", 0);
                put("data", constantItemService.listExtend());
            }
        };
    }

    @RequestMapping("/typeTable.json")
    public Map<String, Object> typeTable() {
        return new HashMap<String, Object>() {
            {
                put("code", 0);
                put("data", constantTypeService.list());
            }
        };
    }
}
